home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
earcd
/
util
/
dir
/
managers.lha
/
Managers
/
Dir
/
Dir.calc
< prev
next >
Wrap
Text File
|
1997-01-15
|
7KB
|
308 lines
G4C
; dir.calc
; A calculator, which uses ARexx to calculate & display the results.
; NOTE : ** means "to the power of" i.e. 5**2 = 25
; Other ARexx operators can be entered manually if needed.
WINBIG 400 24 160 128 "RexxCalc" ; Our window.
WinType 11110001 ; It has all standard gadgets & bottom resize
WINBACKGROUND PATTERN 0 2 ; Add a flashy background..
BOX 0 0 0 0 IN ICONDROP ; A window sized box, taking us way beyond "cool"
;************************** GENERAL EVENTS ***********************************
xONLOAD ; Upon loading of the GUI
setscreen dir.calc $lv_fmscreen
rexxok = 0
ifexists port AREXX ; check if rexx mast is running
;
else
ifexists file rexxmast
run 'rexxmast'
rexxok = 1
else
ifexists file sys:system/rexxmast
run 'sys:system/rexxmast'
rexxok = 1
endif
endif
if $rexxok = 1
wait port AREXX 100
else
ezreq 'RexxMast not found!' OK ""
guiquit dir.calc
stop
endif
endif
ifexists file sys:rexxc/rx ; check for rx & make resident
run 'resident sys:rexxc/rx pure add'
else
ezreq 'Sys:rexxc/RX not found!' OK ""
guiquit dir.calc
stop
endif
setvar calcvar "" ; This is our main variable
setgad dir.calc 2 HIDE ; hide the ticker tape
GUIOPEN dir.calc
setvar mem .mem1 ; These are the Memory variables
setvar .mem1 0 ; The ones starting with a full stop,
setvar .mem2 0 ; are env: variables
setvar .mem3 0
setvar .mem4 0
setvar .mem5 0
setvar membuff ""
setvar .result "0" ; somewhere to put the result (env: variable)
setvar calcmode SMALL ; small/big window
xonclose
guiquit dir.calc
xOnQuit ; On quitting we delete the env variables,
delete env:.mem#? ; so they don't linger in Env:
delvar rexxok
delvar calc#?
delvar mem
delvar membuff
delvar .result
run 'resident rx remove'
;***************************** BUTTONS GALORE ! ******************************
; All these buttons do the same thing. They AppVar their number or letter
; to our main variable and redisplay it
;=======================> The Buttons for the plain numbers
xBUTTON 10 25 25 15 1
gadkey 1 ; Keyboard shortcut
AppVar calcvar 1 ; AppVar the number to "calcvar"
update dir.calc 1 $calcvar ; and re-display it.
xBUTTON 36 25 25 15 2 ; same as above
gadkey 2
AppVar calcvar 2
update dir.calc 1 $calcvar
xBUTTON 62 25 25 15 3
gadkey 3
AppVar calcvar 3
update dir.calc 1 $calcvar
xBUTTON 10 41 25 15 4
gadkey 4
AppVar calcvar 4
update dir.calc 1 $calcvar
xBUTTON 36 41 25 15 5
gadkey 5
AppVar calcvar 5
update dir.calc 1 $calcvar
xBUTTON 62 41 25 15 6
gadkey 6
AppVar calcvar 6
update dir.calc 1 $calcvar
xBUTTON 10 57 25 15 7
gadkey 7
AppVar calcvar 7
update dir.calc 1 $calcvar
xBUTTON 36 57 25 15 8
gadkey 8
AppVar calcvar 8
update dir.calc 1 $calcvar
xBUTTON 62 57 25 15 9
gadkey 9
AppVar calcvar 9
update dir.calc 1 $calcvar
xBUTTON 10 73 25 15 0
gadkey 0
AppVar calcvar 0
update dir.calc 1 $calcvar
xBUTTON 36 73 25 15 .
gadkey .
AppVar calcvar .
update dir.calc 1 $calcvar
xBUTTON 62 73 25 15 < ; backspace
gadkey #8
cutvar calcvar CUT CHAR -1 "" ; It will delete the last character of
update dir.calc 1 $calcvar ; "calcvar" and re-display it
;=========================> The operators
xBUTTON 90 25 25 15 /
gadkey /
AppVar calcvar /
update dir.calc 1 $calcvar
xBUTTON 90 41 25 15 * ; hit twice for square
gadkey *
AppVar calcvar *
update dir.calc 1 $calcvar
xBUTTON 90 57 25 15 -
gadkey -
AppVar calcvar -
update dir.calc 1 $calcvar
xBUTTON 90 73 25 15 +
gadkey +
AppVar calcvar +
update dir.calc 1 $calcvar
;------------- right most bank
xBUTTON 116 25 35 15 (
gadkey (
AppVar calcvar (
update dir.calc 1 $calcvar
xBUTTON 116 41 35 15 )
gadkey )
AppVar calcvar )
update dir.calc 1 $calcvar
xBUTTON 116 57 35 15 CLR ; Clear
gadkey #127
update dir.calc 1 0
setvar calcvar ""
if $calcmode = BIG ; update ticker tape
LVAdd dir.calc 2 '** Clear **'
endif
xBUTTON 116 73 35 15 =
gadkey #13
gosub dir.calc calculate ; GoSub the routine which does the calculation
;===========================> This is our display panel. - Note it's
; a xTEXTin type gadget, so we can enter a calculation directly into it.
xTEXTIN 10 5 140 18 "" calcvar 0 512
GADID 1
gosub dir.calc calculate ; GoSub the routine which does the calculation
;===================> routine to calculate & display result
xROUTINE calculate
if $calcvar > "" ; If there is an entry
if $calcmode = BIG ; update ticker tape
LVAdd dir.calc 2 '$calcvar'
endif
cli "rx 'say >env:.result $calcvar'"
update dir.calc 1 $.result ; and display the answer EVAL returned
setvar calcvar $.result ; We set "calcvar" to the result
if $calcmode = BIG ; update ticker tape
LVAdd dir.calc 2 '=> $calcvar'
endif
if $calcvar = 0
setvar calcvar "" ; and if it's 0, we empty it (looks nicer)
endif
endif
;***************************** MEMORIES **************************************
; If you look at the following code carefully, you will see that we
; need a variable within a variable.
; We use "membuff" to construct such a variable.
;=======================> Memories display panel
xTEXTIN 10 90 140 16 "" $mem 0 30
GadID 5
;=======================> Memories cycler
xCycler 10 108 60 15 "" mem
Cstr "M1" .mem1
Cstr "M2" .mem2
Cstr "M3" .mem3
Cstr "M4" .mem4
Cstr "M5" .mem5
setvar membuff "\$$mem" ; This means set membuff to $ + whatever is in "mem"
update dir.calc 5 $membuff ; so that it points to the correct variable
;=======================> Memory IN/OUT
xButton 70 108 20 15 I ; These buttons do the usual MEM in/out/+/-
SetVar $mem $calcvar ; stuff that calculators do.
setvar membuff "\$$mem"
update dir.calc 5 $membuff
xButton 90 108 20 15 O
setvar membuff "\$$mem"
AppVar calcvar $membuff
update dir.calc 1 $calcvar
xButton 110 108 20 15 +
setvar membuff "\$$mem"
cli "rx 'say >env:$mem $calcvar + $membuff'"
setvar membuff "\$$mem"
update dir.calc 5 $membuff
xButton 130 108 20 15 -
setvar membuff "\$$mem"
cli "rx 'say >env:$mem $membuff - $calcvar'"
setvar membuff "\$$mem"
update dir.calc 5 $membuff
;***************************** Ticker Tape **********************************
; Here we expand the window to include a listview for the ticker tape
; This is done on clicking of the Right Mouse Button
xOnRMB
if $calcmode = SMALL
calcmode = BIG
changegad dir.calc 0 -1 -1 320 128 ""
setgad dir.calc 2 SHOW
else
calcmode = SMALL
lvclear dir.calc 2
changegad dir.calc 0 -1 -1 160 128 ""
setgad dir.calc 2 HIDE
endif
redraw dir.calc
;---- This is the listview that will show the results
; update main calc pannel according to lv line clicked
xListview 155 5 158 123 "" calc.lv "" 10 TXT
gadid 2
cutvar calc.lv copy char 3 calc.3
if $calc.3 = '** '
calcvar = 0
else
if $calc.3 = '=> '
cutvar calc.lv cut char 3 ""
calcvar = $calc.lv
else
calcvar = $calc.lv
endif
endif
update dir.calc 1 $calcvar
if $calcvar = 0
calcvar = ''
endif